attribute vec2 aVertexPosition;

uniform mat3 projectionMatrix;

varying vec2 vTextureCoord;
varying vec2 vRgbCoord;
varying vec2 vAlphaCoord;

uniform vec4 inputSize;
uniform vec4 outputFrame;

vec4 filterVertexPosition( void )
{
    vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;

    return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
}

void computeTextureCoord( void )
{
    vec2 ratio = (outputFrame.zw * inputSize.zw);
    vTextureCoord = aVertexPosition * ratio;

    vAlphaCoord = vTextureCoord * vec2(0.5, 1);
    vRgbCoord = vAlphaCoord + vec2(ratio.x * 0.5, 0);
}

void main(void)
{
    gl_Position = filterVertexPosition();
    computeTextureCoord();
}